-- Empty string, should return default values
SELECT CONVERT(TIME, '')
GO

SELECT CONVERT(TIME, '', 130)
GO

SELECT CONVERT(TIME, '11 AM')
GO

SELECT CONVERT(TIME, '13 AM')
GO

SELECT CONVERT(TIME, '11 PM')
GO

SELECT CONVERT(TIME, '13 PM')
GO

SELECT CONVERT(TIME, '24 PM')
GO

SELECT CONVERT(TIME, '0 PM')
GO

SELECT CONVERT(TIME, '0 AM')
GO

SELECT CONVERT(TIME, '11AM      ')
GO

SELECT CONVERT(TIME, '     13AM')
GO

SELECT CONVERT(TIME, '11PM')
GO

SELECT CONVERT(TIME, '13PM')
GO

SELECT CONVERT(TIME, '24PM')
GO

SELECT CONVERT(TIME, '11')
GO

SELECT CONVERT(TIME, '    11:22    ')
GO

SELECT CONVERT(TIME, '11:22 AM')
GO

SELECT CONVERT(TIME, '11:22 PM')
GO

SELECT CONVERT(TIME, '11:22.123')
GO

SELECT CONVERT(TIME, '11:22.123 AM')
GO

SELECT CONVERT(TIME, '11:22.123 PM')
GO

SELECT CONVERT(TIME, '11:  22   :12')
GO

SELECT CONVERT(TIME, '11:22:12 AM')
GO

SELECT CONVERT(TIME, '11:  22:12 PM')
GO

SELECT CONVERT(TIME, '11 :22:12:123')
GO

SELECT CONVERT(TIME, '11:22:12:1234')
GO

SELECT CONVERT(TIME, '11:22:12:123 AM')
GO

SELECT CONVERT(TIME, '11:22:12  :123 PM')
GO

SELECT CONVERT(TIME, '11:  22:12.123')
GO

SELECT CONVERT(TIME, '11:22:12.  1234')
GO

SELECT CONVERT(TIME, '11:22:12.  123456789')
GO

SELECT CONVERT(TIME, '11:22  :12.1234567891')
GO

SELECT CONVERT(TIME, '11: 22:12.123 AM')
GO

SELECT CONVERT(TIME, '11:22:12.  123234 PM')
GO

-- TIME with typmod
SELECT CONVERT(TIME(0), '01/01/98 23:59:56.501')
GO

SELECT CONVERT(TIME(0), '01/01/98 23:59:56.500')
GO

SELECT CONVERT(TIME(0), '01/01/98 23:59:56.499')
GO

SELECT CONVERT(TIME(1), '01/01/98 23:59:59.123')
GO

SELECT CONVERT(TIME(2), '01/01/98 23:59:59.123')
GO

SELECT CONVERT(TIME(3), '01/01/98 23:59:59.123')
GO

-- -- rounding of minutes or fractional seconds
SELECT CONVERT(TIME, '11:22:12.12345675')
GO

SELECT CONVERT(TIME, '11:22:12.12345674')
GO

-- -- Boundary values
SELECT CONVERT(TIME, '9999-12-30 23:59:59.9999999')
GO

SELECT CONVERT(TIME, '9999-12-30 23:59:59.99999999')
GO

SELECT CONVERT(TIME, '9999-12-30 23:59:59.999999999')
GO

SELECT CONVERT(TIME, '9999-12-30 23:59:59.9999999999')
GO

SELECT CONVERT(TIME, '9999-12-31 23:59:59.9999999')
GO

SELECT CONVERT(TIME, '9999-12-31 23:59:59.99999999')
GO

SELECT CONVERT(TIME, '9999-12-31 23:59:59.999999999')
GO

SELECT CONVERT(TIME, '9999-12-31 23:59:59.9999999999')
GO

SELECT CONVERT(TIME, '11:22:12.129')
GO

SELECT CONVERT(TIME, '11:22:12.128')
GO

SELECT CONVERT(TIME, '11:22:12.127')
GO

SELECT CONVERT(TIME, '11:22:12.126')
GO

SELECT CONVERT(TIME, '11:22:12.125')
GO

SELECT CONVERT(TIME, '11:22:12.124')
GO

SELECT CONVERT(TIME, '11:22:12.123')
GO

SELECT CONVERT(TIME, '11:22:12.122')
GO

SELECT CONVERT(TIME, '11:22:12.121')
GO

SELECT CONVERT(TIME, '11:22:12.120')
GO

SELECT CONVERT(TIME, '11:22:29')
GO

SELECT CONVERT(TIME, '11:22:30')
GO

SELECT CONVERT(TIME, '11 AM +00:00')
GO

SELECT CONVERT(TIME, '13 AM -00:00')
GO

SELECT CONVERT(TIME, '11 PM +00:00')
GO

SELECT CONVERT(TIME, '13 PM -00:00')
GO

SELECT CONVERT(TIME, '24 PM +00:00')
GO

SELECT CONVERT(TIME, '0 PM -00:00')
GO

SELECT CONVERT(TIME, '0 AM +00:00')
GO

SELECT CONVERT(TIME, '11AM       -00:00')
GO

SELECT CONVERT(TIME, '     13AM +00:00')
GO

SELECT CONVERT(TIME, '11PM -00:00')
GO

SELECT CONVERT(TIME, '13PM +00:00')
GO

SELECT CONVERT(TIME, '24PM -00:00')
GO

SELECT CONVERT(TIME, '11 +00:00')
GO

SELECT CONVERT(TIME, '    11:22     -00:00')
GO

SELECT CONVERT(TIME, '11:22 AM -00:00')
GO

SELECT CONVERT(TIME, '11:22 PM +00:00')
GO

SELECT CONVERT(TIME, '11:22.123 -00:00')
GO

SELECT CONVERT(TIME, '11:22.123 AM +00:00')
GO

SELECT CONVERT(TIME, '11:22.123 PM -00:00')
GO

SELECT CONVERT(TIME, '11:  22   :12 +00:00')
GO

SELECT CONVERT(TIME, '11:22:12 AM -00:00')
GO

SELECT CONVERT(TIME, '11:  22:12 PM +00:00')
GO

SELECT CONVERT(TIME, '11 :22:12:123 -00:00')
GO

SELECT CONVERT(TIME, '11:22:12:1234 +00:00')
GO

SELECT CONVERT(TIME, '11:22:12:123 AM -00:00')
GO

SELECT CONVERT(TIME, '11:22:12  :123 PM +00:00')
GO

SELECT CONVERT(TIME, '11:  22:12.123 -00:00')
GO

SELECT CONVERT(TIME, '11:22:12.  1234 +00:00')
GO

SELECT CONVERT(TIME, '11:22:12.  123456789 -00:00')
GO

SELECT CONVERT(TIME, '11:22  :12.1234567891 +00:00')
GO

SELECT CONVERT(TIME, '11: 22:12.123 AM -00:00')
GO

SELECT CONVERT(TIME, '11:22:12.  123234 PM +00:00')
GO

SELECT CONVERT(TIME, '11 AM -05:12')
GO

SELECT CONVERT(TIME, '13 AM +05:12')
GO

SELECT CONVERT(TIME, '11 PM -05:12')
GO

SELECT CONVERT(TIME, '13 PM +05:12')
GO

SELECT CONVERT(TIME, '24 PM -05:12')
GO

SELECT CONVERT(TIME, '0 PM +05:12')
GO

SELECT CONVERT(TIME, '0 AM -05:12')
GO

SELECT CONVERT(TIME, '11AM       +05:12')
GO

SELECT CONVERT(TIME, '     13AM -05:12')
GO

SELECT CONVERT(TIME, '11PM +05:12')
GO

SELECT CONVERT(TIME, '13PM -05:12')
GO

SELECT CONVERT(TIME, '24PM +05:12')
GO

SELECT CONVERT(TIME, '11 -05:12')
GO

SELECT CONVERT(TIME, '    11:22     +05:12')
GO

SELECT CONVERT(TIME, '11:22 AM -05:12')
GO

SELECT CONVERT(TIME, '11:22 PM +05:12')
GO

SELECT CONVERT(TIME, '11:22.123 -05:12')
GO

SELECT CONVERT(TIME, '11:22.123 AM +05:12')
GO

SELECT CONVERT(TIME, '11:22.123 PM -05:12')
GO

SELECT CONVERT(TIME, '11:  22   :12 +05:12')
GO

SELECT CONVERT(TIME, '11:22:12 AM -05:12')
GO

SELECT CONVERT(TIME, '11:  22:12 PM +05:12')
GO

SELECT CONVERT(TIME, '11 :22:12:123 -05:12')
GO

SELECT CONVERT(TIME, '11:22:12:1234 +05:12')
GO

SELECT CONVERT(TIME, '11:22:12:123 AM -05:12')
GO

SELECT CONVERT(TIME, '11:22:12  :123 PM +05:12')
GO

SELECT CONVERT(TIME, '11:  22:12.123 -05:12')
GO

SELECT CONVERT(TIME, '11:22:12.  1234 +05:12')
GO

SELECT CONVERT(TIME, '11:22:12.  123456789 -05:12')
GO

SELECT CONVERT(TIME, '11:22  :12.1234567891 +05:12')
GO

SELECT CONVERT(TIME, '11: 22:12.123 AM -05:12')
GO

SELECT CONVERT(TIME, '11:22:12.  123234 PM +05:12')
GO

SELECT CONVERT(TIME, '11 AM -14:00')
GO

SELECT CONVERT(TIME, '13 AM +14:00')
GO

SELECT CONVERT(TIME, '11 PM -14:00')
GO

SELECT CONVERT(TIME, '13 PM +14:00')
GO

SELECT CONVERT(TIME, '24 PM -14:00')
GO

SELECT CONVERT(TIME, '0 PM +14:00')
GO

SELECT CONVERT(TIME, '0 AM -14:00')
GO

SELECT CONVERT(TIME, '11AM       +14:00')
GO

SELECT CONVERT(TIME, '     13AM -14:00')
GO

SELECT CONVERT(TIME, '11PM +14:00')
GO

SELECT CONVERT(TIME, '13PM -14:00')
GO

SELECT CONVERT(TIME, '24PM +14:00')
GO

SELECT CONVERT(TIME, '11 -14:00')
GO

SELECT CONVERT(TIME, '    11:22     +14:00')
GO

SELECT CONVERT(TIME, '11:22 AM -14:00')
GO

SELECT CONVERT(TIME, '11:22 PM +14:00')
GO

SELECT CONVERT(TIME, '11:22.123 -14:00')
GO

SELECT CONVERT(TIME, '11:22.123 AM +14:00')
GO

SELECT CONVERT(TIME, '11:22.123 PM -14:00')
GO

SELECT CONVERT(TIME, '11:  22   :12 +14:00')
GO

SELECT CONVERT(TIME, '11:22:12 AM -14:00')
GO

SELECT CONVERT(TIME, '11:  22:12 PM +14:00')
GO

SELECT CONVERT(TIME, '11 :22:12:123 -14:00')
GO

SELECT CONVERT(TIME, '11:22:12:1234 +14:00')
GO

SELECT CONVERT(TIME, '11:22:12:123 AM -14:00')
GO

SELECT CONVERT(TIME, '11:22:12  :123 PM +14:00')
GO

SELECT CONVERT(TIME, '11:  22:12.123 -14:00')
GO

SELECT CONVERT(TIME, '11:22:12.  1234 +14:00')
GO

SELECT CONVERT(TIME, '11:22:12.  123456789 -14:00')
GO

SELECT CONVERT(TIME, '11:22  :12.1234567891 +14:00')
GO

SELECT CONVERT(TIME, '11: 22:12.123 AM -14:00')
GO

SELECT CONVERT(TIME, '11:22:12.  123234 PM +14:00')
GO

SELECT CONVERT(TIME, '11 AM -14:10')
GO

SELECT CONVERT(TIME, '13 AM +14:10')
GO

SELECT CONVERT(TIME, '11 PM -14:10')
GO

SELECT CONVERT(TIME, '13 PM +14:10')
GO

SELECT CONVERT(TIME, '24 PM -14:10')
GO

SELECT CONVERT(TIME, '0 PM +14:10')
GO

SELECT CONVERT(TIME, '0 AM -14:10')
GO

SELECT CONVERT(TIME, '11AM       +14:10')
GO

SELECT CONVERT(TIME, '     13AM -14:10')
GO

SELECT CONVERT(TIME, '11PM +14:10')
GO

SELECT CONVERT(TIME, '13PM -14:10')
GO

SELECT CONVERT(TIME, '24PM +14:10')
GO

SELECT CONVERT(TIME, '11 -14:10')
GO

SELECT CONVERT(TIME, '    11:22     +14:10')
GO

SELECT CONVERT(TIME, '11:22 AM -14:10')
GO

SELECT CONVERT(TIME, '11:22 PM +14:10')
GO

SELECT CONVERT(TIME, '11:22.123 -14:10')
GO

SELECT CONVERT(TIME, '11:22.123 AM +14:10')
GO

SELECT CONVERT(TIME, '11:22.123 PM -14:10')
GO

SELECT CONVERT(TIME, '11:  22   :12 +14:10')
GO

SELECT CONVERT(TIME, '11:22:12 AM -14:10')
GO

SELECT CONVERT(TIME, '11:  22:12 PM +14:10')
GO

SELECT CONVERT(TIME, '11 :22:12:123 -14:10')
GO

SELECT CONVERT(TIME, '11:22:12:1234 +14:10')
GO

SELECT CONVERT(TIME, '11:22:12:123 AM -14:10')
GO

SELECT CONVERT(TIME, '11:22:12  :123 PM +14:10')
GO

SELECT CONVERT(TIME, '11:  22:12.123 -14:10')
GO

SELECT CONVERT(TIME, '11:22:12.  1234 +14:10')
GO

SELECT CONVERT(TIME, '11:22:12.  123456789 -14:10')
GO

SELECT CONVERT(TIME, '11:22  :12.1234567891 +14:10')
GO

SELECT CONVERT(TIME, '11: 22:12.123 AM -14:10')
GO

SELECT CONVERT(TIME, '11:22:12.  123234 PM +14:10')
GO

SELECT CONVERT(TIME, '11 AM Z')
GO

SELECT CONVERT(TIME, '13 AM Z')
GO

SELECT CONVERT(TIME, '11 PM Z')
GO

SELECT CONVERT(TIME, '13 PM Z')
GO

SELECT CONVERT(TIME, '24 PM Z')
GO

SELECT CONVERT(TIME, '0 PM Z')
GO

SELECT CONVERT(TIME, '0 AM Z')
GO

SELECT CONVERT(TIME, '11AM      Z')
GO

SELECT CONVERT(TIME, '     13AM Z')
GO

SELECT CONVERT(TIME, '11PM Z')
GO

SELECT CONVERT(TIME, '13PM Z')
GO

SELECT CONVERT(TIME, '24PM Z')
GO

SELECT CONVERT(TIME, '11Z')
GO

SELECT CONVERT(TIME, '    11:22    Z')
GO

SELECT CONVERT(TIME, '11:22 AM Z')
GO

SELECT CONVERT(TIME, '11:22 PM Z')
GO

SELECT CONVERT(TIME, '11:22.123Z')
GO

SELECT CONVERT(TIME, '11:22.123 AM Z')
GO

SELECT CONVERT(TIME, '11:22.123 PM Z')
GO

SELECT CONVERT(TIME, '11:  22   :12Z')
GO

SELECT CONVERT(TIME, '11:22:12 AM Z')
GO

SELECT CONVERT(TIME, '11:  22:12 PM Z')
GO

SELECT CONVERT(TIME, '11 :22:12:123Z')
GO

SELECT CONVERT(TIME, '11:22:12:1234Z')
GO

SELECT CONVERT(TIME, '11:22:12:123 AM Z')
GO

SELECT CONVERT(TIME, '11:22:12  :123 PM Z')
GO

SELECT CONVERT(TIME, '11:  22:12.123Z')
GO

SELECT CONVERT(TIME, '11:22:12.  1234Z')
GO

SELECT CONVERT(TIME, '11:22:12.  123456789Z')
GO

SELECT CONVERT(TIME, '11:22  :12.1234567891Z')
GO

SELECT CONVERT(TIME, '11: 22:12.123 AM Z')
GO

SELECT CONVERT(TIME, '11:22:12.  123234 PM Z')
GO

-- default value if only DATE is passed
SELECT CONVERT(TIME, '2000-04-22')
GO

-- Different DATETIME formats with their corresponding styles
SELECT CONVERT(TIME, 'Apr 10 2021 11:12AM', 0)
GO

SELECT CONVERT(TIME, '02/12/21', 1)
GO

SELECT CONVERT(TIME, '21.02.12', 2)
GO

SELECT CONVERT(TIME, '12/02/21', 3)
GO

SELECT CONVERT(TIME, '12.02.21', 4)
GO

SELECT CONVERT(TIME, '12-02-21', 5)
GO

SELECT CONVERT(TIME, '12 Apr 21', 6)
GO

SELECT CONVERT(TIME, 'Apr 12, 21', 7)
GO

SELECT CONVERT(TIME, '10:13:14', 8)
GO

SELECT CONVERT(TIME, '10:13:14', 24)
GO

SELECT CONVERT(TIME, 'Apr 12 2021 10:13:14:123AM', 9)
GO

SELECT CONVERT(TIME, '02-12-21', 10)
GO

SELECT CONVERT(TIME, '21/02/12', 11)
GO

SELECT CONVERT(TIME, '210212', 12)
GO

SELECT CONVERT(TIME, '12 Apr 2021 15:13:14:123', 13)
GO

SELECT CONVERT(TIME, '15:13:14:123', 14)
GO

SELECT CONVERT(TIME, '2021-02-12 15:13:14', 20)
GO

SELECT CONVERT(TIME, '2021-02-12 15:13:14.123', 21)
GO

SELECT CONVERT(TIME, '02/12/21 15:13:14 PM', 22)
GO

SELECT CONVERT(TIME, '2021-02-12', 23)
GO

SELECT CONVERT(TIME, '2021-02-12 15:13:14.123', 25)
GO

SELECT CONVERT(TIME, 'Apr 10 2021 11:12AM', 100)
GO

SELECT CONVERT(TIME, '02/12/2021', 101)
GO

SELECT CONVERT(TIME, '2021.02.12', 102)
GO

SELECT CONVERT(TIME, '12/02/2021', 103)
GO

SELECT CONVERT(TIME, '12.02.2021', 104)
GO

SELECT CONVERT(TIME, '12-02-2021', 105)
GO

SELECT CONVERT(TIME, '12 Apr 2021', 106)
GO

SELECT CONVERT(TIME, 'Apr 12, 2021', 107)
GO

SELECT CONVERT(TIME, '10:13:14', 108)
GO

SELECT CONVERT(TIME, 'Apr 12 2021 10:13:14:123AM', 109)
GO

SELECT CONVERT(TIME, '02-12-2021', 110)
GO

SELECT CONVERT(TIME, '2021/02/12', 111)
GO

SELECT CONVERT(TIME, '20210212', 112)
GO

SELECT CONVERT(TIME, '12 Apr 2021 15:13:14:123', 113)
GO

SELECT CONVERT(TIME, '15:13:14:123', 114)
GO

SELECT CONVERT(TIME, '2021-02-12 15:13:14', 120)
GO

SELECT CONVERT(TIME, '2021-02-12 15:13:14.123', 121)
GO

SELECT CONVERT(TIME, '2021-02-12T15:13:14.123', 126)
GO

SELECT CONVERT(TIME, '2021-02-12T15:13:14.123', 127)
GO

SELECT CONVERT(TIME, N'22 محرم 1440 1:39:17.090', 130)
GO

SELECT CONVERT(TIME, '12/02/2021 15:13:14:123 PM', 131)
GO

-- -- misc
SELECT CONVERT(TIME,'2022-10-29 20:01:00.000')
GO

SELECT CONVERT(TIME, '2020')
GO

SELECT CONVERT(TIME, '2000-04-22 16:23:51.7668c0')
GO

SELECT CONVERT(TIME, '2000-04-22 16:23:51.7668c0')
GO

SELECT CONVERT(TIME, '2001-04-022 16:23:51.766890 +12:00')
GO

SELECT CONVERT(TIME, '02001-04-22 16:23:51.766890 +12:00') 
GO 

SELECT CONVERT(TIME, ' 2001- 04 - 22 16: 23: 51. 766890 +12:00')
GO

SELECT CONVERT(TIME, '02001-04-22 16:23:51')
GO

SELECT CONVERT(TIME, '1900-05-06 13:59:29.050 -8:00')
GO

SELECT CONVERT(TIME, '2011-08-15 14:30.00')
GO

SELECT CONVERT(TIME, '2011-08-15 14:30.00')
GO

SELECT CONVERT(TIME,'2022-10-29 20:01:00.000')
GO

SELECT CONVERT(TIME, '2020')
GO

SELECT CONVERT(TIME, '2022-10-30T03:00:00')
GO

DECLARE @TM_ICLO TIME = '17:24:07.1766670'
SELECT CONVERT(TIME, @TM_ICLO)
GO

-- Dependent objects
SELECT * FROM test_conv_string_to_time_v1
GO
EXEC test_conv_string_to_time_p1
GO
SELECT test_conv_string_to_time_f1()
GO

SELECT * FROM test_conv_string_to_time_v2
GO
EXEC test_conv_string_to_time_p2
GO
SELECT test_conv_string_to_time_f2()
GO

SELECT * FROM test_conv_string_to_time_v3
GO
EXEC test_conv_string_to_time_p3
GO
SELECT test_conv_string_to_time_f3()
GO

SELECT * FROM test_conv_string_to_time_v4
GO
EXEC test_conv_string_to_time_p4
GO
SELECT test_conv_string_to_time_f4()
GO

SELECT * FROM test_conv_string_to_time_v5
GO
EXEC test_conv_string_to_time_p5
GO
SELECT test_conv_string_to_time_f5()
GO

SELECT * FROM test_conv_string_to_time_v6
GO
EXEC test_conv_string_to_time_p6
GO
SELECT test_conv_string_to_time_f6()
GO

SELECT * FROM test_conv_string_to_time_v7
GO
EXEC test_conv_string_to_time_p7
GO
SELECT test_conv_string_to_time_f7()
GO

SELECT * FROM test_conv_string_to_time_v8
GO
EXEC test_conv_string_to_time_p8
GO
SELECT test_conv_string_to_time_f8()
GO

SELECT * FROM test_conv_string_to_time_v9
GO
EXEC test_conv_string_to_time_p9
GO
SELECT test_conv_string_to_time_f9()
GO

SELECT * FROM test_conv_string_to_time_v10
GO

SELECT * FROM test_conv_string_to_time_v11
GO

SELECT * FROM test_conv_string_to_time_v12
GO
